package com.wing.wcabinet.service;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wing.cabinet.model.response.CellSingleInventoryProductVO;
import com.wing.wcabinet.dao.WcabCellSingleInventoryProductDao;
import com.wing.wcabinet.model.entity.WcabCellSingleInventoryProduct;
import com.wing.wcabinet.model.request.WcabCellSingleInventoryProductForm;
import com.wing.wcabinet.model.response.WcabCellSingleInventoryProductVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 售刀柜sku库存(某个柜子)-ServiceImpl
 *
 * @author
 */
@Service
@Slf4j
public class WcabCellSingleInventoryProductServiceImpl extends ServiceImpl<WcabCellSingleInventoryProductDao, WcabCellSingleInventoryProduct> implements WcabCellSingleInventoryProductService {

    @Override
    public int add(WcabCellSingleInventoryProductForm wcabCellSingleInventoryProductForm) {

        //校验

        WcabCellSingleInventoryProduct wcabCellSingleInventoryProduct =new WcabCellSingleInventoryProduct();
        CopyOptions copyOptions = CopyOptions.create()
        .setEditable(WcabCellSingleInventoryProduct.class)
        .setIgnoreError(true)
        .setIgnoreNullValue(true);
        BeanUtil.copyProperties(wcabCellSingleInventoryProductForm, wcabCellSingleInventoryProduct, copyOptions);

        return baseMapper.insert(wcabCellSingleInventoryProduct);
    }

    @Override
    public List<WcabCellSingleInventoryProductVO> list4app(Map<String, Object> params) {
        return baseMapper.list4app(params);
    }

    @Override
    public Page<WcabCellSingleInventoryProductVO> pageList4app(Page page, Map<String, Object> params) {
        List<WcabCellSingleInventoryProductVO> list = baseMapper.list4app(page, params);
        page.setRecords(list);
        return page;
    }

    @Override
    public Page<WcabCellSingleInventoryProductVO> pageList(Page page, Map<String, Object> params) {
        List<WcabCellSingleInventoryProductVO> list = baseMapper.list(page, params);
        page.setRecords(list);
        return page;
    }

    @Override
    public Page<WcabCellSingleInventoryProductVO> pageList4Alarm(Page page, Map<String, Object> params) {
        List<WcabCellSingleInventoryProductVO> list = baseMapper.list4Alarm(page, params);
        page.setRecords(list);
        return page;
    }

    @Override
    public Page<WcabCellSingleInventoryProductVO> pageList4AlarmByQuantity(Page page, Map<String, Object> params) {
        List<WcabCellSingleInventoryProductVO> list = baseMapper.list4AlarmByQuantity(page, params);
        page.setRecords(list);
        return page;
    }

    @Override
    public Page<WcabCellSingleInventoryProductVO> pageList4ChildCab(Page page, Map<String, Object> params) {
        List<WcabCellSingleInventoryProductVO> list = baseMapper.list4ChildCab(page, params);
        page.setRecords(list);
        return page;
    }

    @Override
    public Page<WcabCellSingleInventoryProductVO> pageList4MainCab(Page page, Map<String, Object> params) {
        List<WcabCellSingleInventoryProductVO> list = baseMapper.list4MainCab(page, params);
        page.setRecords(list);
        return page;
    }

    @Override
    public Page<WcabCellSingleInventoryProductVO> getInventoryBySkuCodeAndBelongCabinet(Page page, Map<String, Object> params) {
        List<WcabCellSingleInventoryProductVO> list = baseMapper.getInventoryBySkuCodeAndBelongCabinet(page, params);
        page.setRecords(list);
        return page;
    }

    @Override
    public WcabCellSingleInventoryProductVO get4appById(Long id) {
        return baseMapper.get4appById(id);
    }

    @Override
    public Page<WcabCellSingleInventoryProductVO> pageListSku4app(Page page, Map<String, Object> params) {
        List<WcabCellSingleInventoryProductVO> list = baseMapper.listSku4app(page, params);
        page.setRecords(list);
        return page;
    }
}
